class CreateAirports < ActiveRecord::Migration
  def self.up
    create_table :airports do |t|
      t.string :airport_name       ,:limit => 30
      t.string :name_index         ,:limit => 2
      t.string :airport_code       ,:limit => 6 
      t.string :py                 ,:limit => 16  # 拼音
      t.integer :is_locked         ,:limit => 1 ,:default => 0 #是否管理会要锁定 1为True 0为False
      t.timestamps
    end
    
    add_index :airports, :py
    add_index :airports, :airport_code ,:unique=>true
    
    Airport.create(:airport_name =>'A 阿克苏 温宿机场',:name_index=>'A',:airport_code=>'AKU',:py=>'AKS')
    Airport.create(:airport_name =>'A 阿勒泰 阿勒泰机场',:name_index=>'A',:airport_code=>'AAT',:py=>'ALT')
    Airport.create(:airport_name =>'A 安康 五理铺机场',:name_index=>'A',:airport_code=>'AKA',:py=>'AK')
    Airport.create(:airport_name =>'B 包头 包头机场',:name_index=>'B',:airport_code=>'BAV',:py=>'BT')
    Airport.create(:airport_name =>'B 保山 云端机场',:name_index=>'B',:airport_code=>'BSD',:py=>'BS')
    Airport.create(:airport_name =>'B 北海 福城机场',:name_index=>'B',:airport_code=>'BHY',:py=>'BH')
    Airport.create(:airport_name =>'B 北京 首都机场',:name_index=>'B',:airport_code=>'PEK',:py=>'BJ') #BJS
    Airport.create(:airport_name =>'C 长春 龙嘉机场',:name_index=>'C',:airport_code=>'CGQ',:py=>'CC')
    Airport.create(:airport_name =>'C 长沙 黄花机场',:name_index=>'C',:airport_code=>'CSX',:py=>'CS')
    Airport.create(:airport_name =>'C 长治 王村机场',:name_index=>'C',:airport_code=>'CIH',:py=>'CJ')
    Airport.create(:airport_name =>'C 常德 斗姆湖机场',:name_index=>'C',:airport_code=>'CGD',:py=>'CD')
    Airport.create(:airport_name =>'C 常州 奔牛机场',:name_index=>'C',:airport_code=>'CZX',:py=>'CZ')
    Airport.create(:airport_name =>'C 成都 双流机场',:name_index=>'C',:airport_code=>'CTU',:py=>'CD')
    Airport.create(:airport_name =>'C 赤峰 赤峰机场',:name_index=>'C',:airport_code=>'CIF',:py=>'CF')
    Airport.create(:airport_name =>'D 大理 大理机场',:name_index=>'D',:airport_code=>'DLU',:py=>'DD')
    Airport.create(:airport_name =>'D 大连 周水子机场',:name_index=>'D',:airport_code=>'DLC',:py=>'DL')
    Airport.create(:airport_name =>'D 大同 倍加造机场',:name_index=>'D',:airport_code=>'DAT',:py=>'DT')
    Airport.create(:airport_name =>'K 库尔勒 库尔勒机场',:name_index=>'K',:airport_code=>'KRL',:py=>'KEL')
    Airport.create(:airport_name =>'Y 榆林 西沙机场',:name_index=>'Y',:airport_code=>'UYN',:py=>'YL')
    Airport.create(:airport_name =>'W 温州 永强机场',:name_index=>'W',:airport_code=>'WNZ',:py=>'WZ')
    Airport.create(:airport_name =>'Q 青岛 流亭机场',:name_index=>'Q',:airport_code=>'TAO',:py=>'QD')
    Airport.create(:airport_name =>'L 兰州 中川机场',:name_index=>'L',:airport_code=>'LHW',:py=>'LZ')
    Airport.create(:airport_name =>'Z 昭通 昭通机场',:name_index=>'Z',:airport_code=>'ZAT',:py=>'ZT')
    Airport.create(:airport_name =>'W 武夷山 武夷山机场',:name_index=>'W',:airport_code=>'WUS',:py=>'WYS')
    Airport.create(:airport_name =>'Q 泉州 晋江机场',:name_index=>'Q',:airport_code=>'JJN',:py=>'QZ')
    Airport.create(:airport_name =>'L 临沂 临沂机场',:name_index=>'L',:airport_code=>'LYI',:py=>'LY')
    Airport.create(:airport_name =>'Z 舟山 普陀山机场',:name_index=>'Z',:airport_code=>'HSN',:py=>'ZS')
    Airport.create(:airport_name =>'X 西宁 曹家堡机场',:name_index=>'X',:airport_code=>'XNN',:py=>'XN')
    Airport.create(:airport_name =>'S 上海 虹桥机场',:name_index=>'S',:airport_code=>'SHA',:py=>'SH')
    Airport.create(:airport_name =>'S 上海 浦东机场',:name_index=>'S',:airport_code=>'PVG',:py=>'SH')
    Airport.create(:airport_name =>'S 深圳 宝安机场',:name_index=>'S',:airport_code=>'SZX',:py=>'SZ')
    Airport.create(:airport_name =>'S 沈阳 仙桃机场',:name_index=>'S',:airport_code=>'SHE',:py=>'SY')
    Airport.create(:airport_name =>'S 石家庄 正定机场',:name_index=>'S',:airport_code=>'SJW',:py=>'SJZ')
    Airport.create(:airport_name =>'S 思茅 思茅机场',:name_index=>'S',:airport_code=>'SYM',:py=>'SM')
    Airport.create(:airport_name =>'T 塔城 塔城机场',:name_index=>'T',:airport_code=>'TCG',:py=>'TC')
    Airport.create(:airport_name =>'T 太原 武宿机场',:name_index=>'T',:airport_code=>'TYN',:py=>'TY')
    Airport.create(:airport_name =>'T 天津 滨海机场',:name_index=>'T',:airport_code=>'TSN',:py=>'TJ')
    Airport.create(:airport_name =>'T 通辽 通辽机场',:name_index=>'T',:airport_code=>'TGO',:py=>'TL')
    Airport.create(:airport_name =>'T 铜人 大兴机场',:name_index=>'T',:airport_code=>'TEN',:py=>'TR')
    Airport.create(:airport_name =>'W 万州 万州机场',:name_index=>'W',:airport_code=>'WXN',:py=>'WZ')
    Airport.create(:airport_name =>'W 威海 大水泊机场',:name_index=>'W',:airport_code=>'WEH',:py=>'WH')
    Airport.create(:airport_name =>'D 丹东 浪头机场',:name_index=>'D',:airport_code=>'DDG',:py=>'DD')
    Airport.create(:airport_name =>'D 德宏 芒市机场',:name_index=>'D',:airport_code=>'LUM',:py=>'DH')
    Airport.create(:airport_name =>'D 迪庆 香格里拉机场',:name_index=>'D',:airport_code=>'DIG',:py=>'DQ')
    Airport.create(:airport_name =>'D 东营 东营机场',:name_index=>'D',:airport_code=>'DOY',:py=>'DY')
    Airport.create(:airport_name =>'D 敦煌 敦煌机场',:name_index=>'D',:airport_code=>'DNH',:py=>'DH')
    Airport.create(:airport_name =>'E 恩施 许家坪机场',:name_index=>'E',:airport_code=>'ENH',:py=>'ES')
    Airport.create(:airport_name =>'F 福州 长乐机场',:name_index=>'F',:airport_code=>'FOC',:py=>'FZ')
    Airport.create(:airport_name =>'G 赣州 黄金机场',:name_index=>'G',:airport_code=>'KOW',:py=>'GZ')
    Airport.create(:airport_name =>'G 格尔木 格尔木机场',:name_index=>'G',:airport_code=>'GOQ',:py=>'GEM')
    Airport.create(:airport_name =>'G 广州 白云机场',:name_index=>'G',:airport_code=>'CAN',:py=>'GZ')
    Airport.create(:airport_name =>'G 贵阳 龙洞堡机场',:name_index=>'G',:airport_code=>'KWE',:py=>'GY')
    Airport.create(:airport_name =>'G 桂林 两江机场',:name_index=>'G',:airport_code=>'KWL',:py=>'GL')
    Airport.create(:airport_name =>'H 哈尔滨 太平机场',:name_index=>'H',:airport_code=>'HRB',:py=>'HEB')
    Airport.create(:airport_name =>'H 海口 美兰机场',:name_index=>'H',:airport_code=>'HAK',:py=>'HK')
    Airport.create(:airport_name =>'H 海拉尔 东山机场',:name_index=>'H',:airport_code=>'HLD',:py=>'HLE')
    Airport.create(:airport_name =>'H 汉中 西关机场',:name_index=>'H',:airport_code=>'HZG',:py=>'HZ')
    Airport.create(:airport_name =>'H 杭州 萧山机场',:name_index=>'H',:airport_code=>'HGH',:py=>'HZ')
    Airport.create(:airport_name =>'Q 且末 且末机场',:name_index=>'Q',:airport_code=>'IQM',:py=>'QM')
    Airport.create(:airport_name =>'Q 昆明 巫家坝机场',:name_index=>'Q',:airport_code=>'KMG',:py=>'KM')
    Airport.create(:airport_name =>'Z 湛江 湛江机场',:name_index=>'Z',:airport_code=>'ZHA',:py=>'ZJ')
    Airport.create(:airport_name =>'W 乌鲁木齐 地窝铺机场',:name_index=>'W',:airport_code=>'URC',:py=>'WLMQ')
    Airport.create(:airport_name =>'Q 庆阳 庆阳机场',:name_index=>'Q',:airport_code=>'IQN',:py=>'QY')
    Airport.create(:airport_name =>'L 丽江 丽江机场',:name_index=>'L',:airport_code=>'LJG',:py=>'LJ')
    Airport.create(:airport_name =>'Z 郑州 新郑机场',:name_index=>'Z',:airport_code=>'CGO',:py=>'ZZ')
    Airport.create(:airport_name =>'X 西安 咸阳机场',:name_index=>'X',:airport_code=>'XIY',:py=>'XA') #SIA
    Airport.create(:airport_name =>'S 三亚 凤凰机场',:name_index=>'S',:airport_code=>'SYX',:py=>'SY')
    Airport.create(:airport_name =>'L 柳州 白莲机场',:name_index=>'L',:airport_code=>'LZH',:py=>'LZ')
    Airport.create(:airport_name =>'Z 珠海 三灶机场',:name_index=>'Z',:airport_code=>'ZUH',:py=>'ZH')
    Airport.create(:airport_name =>'X 锡林浩特 锡林浩特机场',:name_index=>'X',:airport_code=>'XIL',:py=>'XLGL')
    Airport.create(:airport_name =>'X 厦门 高崎机场',:name_index=>'X',:airport_code=>'XMN',:py=>'XM')
    Airport.create(:airport_name =>'X 香港 香港机场',:name_index=>'X',:airport_code=>'HKG',:py=>'XG')
    Airport.create(:airport_name =>'X 襄樊 刘集机场',:name_index=>'X',:airport_code=>'XFN',:py=>'XF')
    Airport.create(:airport_name =>'X 徐州 观音机场',:name_index=>'X',:airport_code=>'XUZ',:py=>'XZ')
    Airport.create(:airport_name =>'Y 烟台 莱山机场',:name_index=>'Y',:airport_code=>'YNT',:py=>'YT')
    Airport.create(:airport_name =>'Y 延安 二十里铺机场',:name_index=>'Y',:airport_code=>'ENY',:py=>'YA')
    Airport.create(:airport_name =>'Y 延吉 朝阳川机场',:name_index=>'Y',:airport_code=>'YNJ',:py=>'YJ')
    Airport.create(:airport_name =>'Y 伊宁 伊宁机场',:name_index=>'Y',:airport_code=>'YIN',:py=>'YN')#伊宁和银川全是YIN?
    Airport.create(:airport_name =>'Y 宜宾 莱坝机场',:name_index=>'Y',:airport_code=>'YBP',:py=>'YB')
    Airport.create(:airport_name =>'Y 宜昌 三峡机场',:name_index=>'Y',:airport_code=>'YIH',:py=>'YC')
    Airport.create(:airport_name =>'Y 义乌 义乌机场',:name_index=>'Y',:airport_code=>'YIW',:py=>'YW')
    Airport.create(:airport_name =>'Y 银川 河东机场',:name_index=>'Y',:airport_code=>'INC',:py=>'YC')
    Airport.create(:airport_name =>'H 合肥 骆岗机场',:name_index=>'H',:airport_code=>'HFE',:py=>'HF')
    Airport.create(:airport_name =>'H 和田 和田机场',:name_index=>'H',:airport_code=>'HTN',:py=>'HT')
    Airport.create(:airport_name =>'H 黑河 黑河机场',:name_index=>'H',:airport_code=>'HEK',:py=>'HH')
    Airport.create(:airport_name =>'H 呼和浩特 白塔机场',:name_index=>'H',:airport_code=>'HET',:py=>'HHHT')
    Airport.create(:airport_name =>'H 黄山 电溪机场',:name_index=>'H',:airport_code=>'TXN',:py=>'HS')
    Airport.create(:airport_name =>'H 黄岩 路桥机场',:name_index=>'H',:airport_code=>'HYA',:py=>'HY')
    Airport.create(:airport_name =>'J 济南 遥墙机场',:name_index=>'J',:airport_code=>'TNA',:py=>'JN')
    Airport.create(:airport_name =>'J 佳木斯 东郊机场',:name_index=>'J',:airport_code=>'JMU',:py=>'JMS')
    Airport.create(:airport_name =>'J 嘉峪关 嘉峪关机场',:name_index=>'J',:airport_code=>'JGN',:py=>'JYG')
    Airport.create(:airport_name =>'J 锦州 小岭子机场',:name_index=>'J',:airport_code=>'JNZ',:py=>'JZ')
    Airport.create(:airport_name =>'J 景德镇 景德镇机场',:name_index=>'J',:airport_code=>'JDZ',:py=>'JDZ')
    Airport.create(:airport_name =>'J 景洪/西双版纳 嘎洒机场',:name_index=>'J',:airport_code=>'JHG',:py=>'XSBN')
    Airport.create(:airport_name =>'J 九江 九江机场',:name_index=>'J',:airport_code=>'JIU',:py=>'JJ')
    Airport.create(:airport_name =>'J 九寨 黄龙机场',:name_index=>'J',:airport_code=>'JZH',:py=>'JZ')
    Airport.create(:airport_name =>'K 喀什 喀什机场',:name_index=>'K',:airport_code=>'KHG',:py=>'KS')
    Airport.create(:airport_name =>'K 克拉玛依 克拉玛依机场',:name_index=>'K',:airport_code=>'KRY',:py=>'KLMY')
    Airport.create(:airport_name =>'K 库车 库车机场',:name_index=>'K',:airport_code=>'KCA',:py=>'KC')
    Airport.create(:airport_name =>'W 潍坊 潍坊机场',:name_index=>'W',:airport_code=>'WEF',:py=>'WF')
    Airport.create(:airport_name =>'Q 秦皇岛 秦皇岛机场',:name_index=>'Q',:airport_code=>'SHP',:py=>'QHD')
    Airport.create(:airport_name =>'L 拉萨 贡嘎机场',:name_index=>'L',:airport_code=>'LXA',:py=>'GG')
    Airport.create(:airport_name =>'Z 张家界 荷花机场',:name_index=>'Z',:airport_code=>'DYG',:py=>'HH')
    Airport.create(:airport_name =>'W 武汉 天河机场',:name_index=>'W',:airport_code=>'WUH',:py=>'WH')
    Airport.create(:airport_name =>'Q 衢州 衢州机场',:name_index=>'Q',:airport_code=>'JUZ',:py=>'QZ')
    Airport.create(:airport_name =>'L 连云港 白塔阜机场',:name_index=>'L',:airport_code=>'LYG',:py=>'LYG')
    Airport.create(:airport_name =>'C 重庆 江北机场',:name_index=>'C',:airport_code=>'CKG',:py=>'CQ')
    Airport.create(:airport_name =>'X 西昌 青山机场',:name_index=>'X',:airport_code=>'XIC',:py=>'XC')
    Airport.create(:airport_name =>'S 汕头 外砂机场',:name_index=>'S',:airport_code=>'SWA',:py=>'ST')
    Airport.create(:airport_name =>'L 泸州 兰田坝机场',:name_index=>'L',:airport_code=>'LZO',:py=>'LZ')
    Airport.create(:airport_name =>'L 洛阳 北郊机场',:name_index=>'L',:airport_code=>'LYA',:py=>'LY')
    Airport.create(:airport_name =>'M 梅县 梅县机场',:name_index=>'M',:airport_code=>'MXZ',:py=>'MX')
    Airport.create(:airport_name =>'M 绵阳 南郊机场',:name_index=>'M',:airport_code=>'MIG',:py=>'MY')
    Airport.create(:airport_name =>'M 牡丹江 海浪机场',:name_index=>'M',:airport_code=>'MOG',:py=>'MDJ')
    Airport.create(:airport_name =>'N 南昌 昌北机场',:name_index=>'N',:airport_code=>'KHN',:py=>'NC')
    Airport.create(:airport_name =>'N 南充 南芜机场',:name_index=>'N',:airport_code=>'NAO',:py=>'NC')
    Airport.create(:airport_name =>'N 南京 禄口机场',:name_index=>'N',:airport_code=>'NKG',:py=>'NJ')
    Airport.create(:airport_name =>'N 南宁 吴墟机场',:name_index=>'N',:airport_code=>'NNG',:py=>'NN')
    Airport.create(:airport_name =>'N 南通 兴东机场',:name_index=>'N',:airport_code=>'NTG',:py=>'NT')
    Airport.create(:airport_name =>'N 南阳 姜营机场',:name_index=>'N',:airport_code=>'NNY',:py=>'NY')
    Airport.create(:airport_name =>'N 宁波 栎社机场',:name_index=>'N',:airport_code=>'NGB',:py=>'NB')
    Airport.create(:airport_name =>'Q 齐齐哈尔 三家子机场',:name_index=>'Q',:airport_code=>'NDG',:py=>'QQHE')
  end
  
  def self.down
    drop_table :airports
  end
end
